{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "35857d17",
   "metadata": {},
   "source": [
    "## *2023-11-01\n",
    "## *课程：python语言\n",
    "## *week07"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e347b004",
   "metadata": {},
   "source": [
    "#  课前内容：认知数据结构\n",
    "### 1.类比\n",
    "### 2.元组\n",
    "### 3.集合\n",
    "### 4.字典\n",
    "### 5.“一切皆为对象”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fcae21fc",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "## 1.列表的概念\n",
    "## 2.列表的性质\n",
    "## 3.列表的一般方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "01e53e2d",
   "metadata": {},
   "source": [
    "# 1.列表的概念\n",
    "   ·思考：如果想要存放一个班级的同学的名字，目前我们有什么方法？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ff227ca4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "张三 李华 李鹏\n"
     ]
    }
   ],
   "source": [
    "# 第一种方法\n",
    "name01 = \"张三\"\n",
    "name02 = \"李华\"\n",
    "name03 = \"李鹏\"\n",
    "print(name01,name02,name03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e78c230a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "张三，李华，李鹏，李小明\n"
     ]
    }
   ],
   "source": [
    "# 第二种方式\n",
    "name = \"张三，李华，李鹏，李小明\"\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "626b42c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李鹏'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 尝试取值：李鹏\n",
    "name[6:8]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10a9bebe",
   "metadata": {},
   "source": [
    "·综上所述，列表就诞生了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "20285c36",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['张三', '李华', '李鹏', '李小明']\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "name_list = [\"张三\",\"李华\",\"李鹏\",\"李小明\"]\n",
    "print(name_list)\n",
    "print(type(name_list))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "eddff6f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李鹏'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#序号：0 1 2 3\n",
    "name_list[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3aa48411",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李华', '李鹏', '李小明']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad6cff52",
   "metadata": {},
   "source": [
    "# 2.列表的性质\n",
    "## 2.1 列表的有序性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ec88a55b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'张三'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "fd825ab3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c7231419",
   "metadata": {},
   "source": [
    "## 2.2 列表的可变性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "551baca7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李华', '李鹏', '李树人']"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6ae6cf50",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李华', '李鹏', '李树人']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list[3]=\"李树人\"\n",
    "name_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7082e543",
   "metadata": {},
   "source": [
    "## 2.3列表存放不同的结构数据的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ff03e9fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', 18, '李华', 19, '李鹏', 20, '李树人', 21]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_age_list =['张三', 18,'李华',19, '李鹏',20, '李树人',21]\n",
    "name_age_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d31614c",
   "metadata": {},
   "source": [
    "## 2.4 列表重复性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "924e0c90",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[95, 96, 94, 98, 97, 87]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_python =[95,96,94,98,97,87]\n",
    "网新_python"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae9b20ba",
   "metadata": {},
   "source": [
    "## 3.列表的方法\n",
    "> 1. 列表的创建\n",
    ">>1. 直接用[ ] 创建列表，中间的元素用英文的 , 隔开\n",
    ">>2. 使用list()创建列表\n",
    "> 2. 列表的处理\n",
    ">>1. 取值\n",
    ">>2. 查询\n",
    ">>3. 增加\n",
    ">>4. 删除"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efcf2b70",
   "metadata": {},
   "source": [
    "## 3.1列表的创建"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "31218d35",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "# 使用list()列表创造器创建列表\n",
    "my_list1 = list((1, 2, 3))\n",
    "print(my_list1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4bb5d4cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n"
     ]
    }
   ],
   "source": [
    "my_list2 = [1, 2, 3]\n",
    "print(my_list2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "c7e16b62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建空列表\n",
    "my_list3=list()\n",
    "my_list3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "d0b47d5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_list4=[]\n",
    "my_list4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7017f1ea",
   "metadata": {},
   "source": [
    "## 3.2 列表的方法\n",
    "### 1.列表的取值\n",
    "> 1. index 取单个值\n",
    "> 2. 切片截取多个值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "6e7190c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['张三', '李华', '李鹏', '李小明']\n"
     ]
    }
   ],
   "source": [
    "name_list = [\"张三\",\"李华\",\"李鹏\",\"李小明\"]\n",
    "print(name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0d2ecbd3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取出 李华 同学的名字（取值）\n",
    "name_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "cdf37aa6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李鹏', '李小明']"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过切片取出后两位同学的名字 \n",
    "name_list[-2:]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14fe7be1",
   "metadata": {},
   "source": [
    "### 2.列表的查询\n",
    "* in方法作为python的一个特殊方法，不仅可以在列表数据使用，其他数据也可\n",
    "* len()对数据长度（范围）方法进行查询，不仅可以在列表数据使用，其他数据也可"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "a52ace43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"张三\" in name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "65dee063",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"小鹏\" in name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "6e88af64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(name_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9243f49e",
   "metadata": {},
   "source": [
    "###  3.关于列表的新增 \n",
    "> 1. append()增加于最后一位\n",
    "> 2. insert() 插入、嵌入\n",
    "> 3."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "ec31ce60",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['张三', '李华', '李鹏', '李小明']\n"
     ]
    }
   ],
   "source": [
    "name_list = [\"张三\",\"李华\",\"李鹏\",\"李小明\"]\n",
    "print(name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "bcb99f97",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李华', '李鹏', '李小明', 'lay']"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list.append(\"lay\") \n",
    "name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "24689c86",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(name_list.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "593aee22",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# insert (index 为索引)\n",
    "help(name_list.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "0c92c5dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李华', 'yoyo', '李鹏', '李小明', 'lay']"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#   0,    1,    2,    3   ( 取值 )\n",
    "  张三，李华，李鹏，李小明 \n",
    "    #插入于前面\n",
    "name_list.insert(2,\"yoyo\")\n",
    "name_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ec7953a",
   "metadata": {},
   "source": [
    "* 临时讲一个方法：count()统计某个元素在列表中出现的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "56a826a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[95, 96, 95, 98, 97, 87]"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_python =[95,96,95,98,97,87]\n",
    "网新_python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "cdad18ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_python.count(95)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a45378e",
   "metadata": {},
   "source": [
    "* 综合实践：\n",
    "* 投色子1000次，分别统计每一个色子面出现的次数\n",
    "> 1. 创建一个空列表\n",
    "> 2. 通过append方法将每一次产生的色子数存进去\n",
    "> 3. 通过count方法查询每一次色子面的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "dc888e93",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1000\n",
      "[3, 4, 5, 2, 1, 2, 4, 2, 1, 2, 5, 4, 6, 4, 6, 3, 6, 4, 1, 5, 3, 4, 6, 2, 2, 5, 3, 4, 3, 3, 6, 5, 1, 3, 1, 1, 4, 3, 5, 4, 4, 6, 3, 2, 2, 6, 1, 5, 4, 2, 5, 1, 6, 5, 5, 4, 4, 2, 4, 4, 1, 1, 5, 4, 3, 6, 3, 6, 5, 1, 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 6, 2, 4, 5, 2, 4, 3, 3, 3, 2, 1, 6, 5, 4, 6, 2, 6, 3, 5, 6, 5, 4, 1, 5, 5, 6, 4, 5, 4, 3, 4, 5, 2, 5, 1, 2, 2, 5, 3, 3, 2, 1, 2, 1, 3, 6, 4, 4, 2, 2, 1, 5, 2, 3, 2, 2, 6, 3, 2, 2, 4, 3, 3, 6, 1, 3, 6, 1, 2, 6, 3, 5, 3, 4, 3, 2, 1, 2, 4, 6, 3, 5, 3, 6, 5, 3, 5, 3, 5, 6, 4, 5, 1, 4, 5, 6, 6, 3, 4, 2, 4, 3, 6, 3, 5, 6, 1, 5, 4, 5, 1, 2, 5, 1, 5, 2, 6, 6, 6, 1, 4, 6, 2, 4, 6, 2, 1, 1, 5, 1, 4, 5, 1, 4, 5, 4, 2, 4, 2, 2, 6, 1, 2, 2, 5, 2, 1, 4, 4, 5, 5, 6, 2, 3, 4, 6, 1, 2, 2, 2, 3, 4, 5, 6, 4, 2, 1, 3, 3, 6, 5, 1, 2, 2, 5, 4, 2, 4, 3, 4, 2, 1, 1, 4, 6, 5, 6, 4, 3, 4, 3, 4, 1, 1, 1, 6, 1, 2, 2, 1, 1, 6, 4, 6, 3, 5, 5, 6, 5, 3, 1, 4, 2, 6, 3, 5, 1, 1, 3, 3, 1, 6, 5, 2, 1, 2, 1, 4, 6, 5, 2, 6, 3, 4, 2, 4, 3, 3, 6, 5, 2, 4, 4, 1, 2, 4, 3]\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "色子出现的数值列表 = []\n",
    "for i in range (1000):\n",
    "    色子出现的数值列表.append(random.randint(1,6))\n",
    "#    print(random.randint(1,6))\n",
    "print(len(色子出现的数值列表)) #看下列表的长度\n",
    "print(色子出现的数值列表)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "9fec1c5c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 154\n",
      "2 177\n",
      "3 182\n",
      "4 161\n",
      "5 163\n",
      "6 163\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,7):\n",
    "    print(i,色子出现的数值列表.count(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "3e8e0210",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function count:\n",
      "\n",
      "count(value, /) method of builtins.list instance\n",
      "    Return number of occurrences of value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(色子出现的数值列表.count)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "daaab9aa",
   "metadata": {},
   "source": [
    "# 课后作业：\n",
    "## 总结列表的方法\n",
    "\n",
    "|方法名称 | 使用说明 | 注意事项 |案例 |\n",
    "|：-----：|：------：|：------：|：--：|\n",
    "|append()方法 |在列表的末尾新增元素| 可以新建空列表，然后通过新增数据的方式创建数据列表|name_list.append(\"lay\")|\n",
    "|insert()方法|insert(index, object, /) method of builtins.list instance Insert object before index.|before index|name_list.insert(2,\"yoyo\")|\n",
    "|count()|count(value, /) method of builtins.list instance Return number of occurrences of value.|如果value不存在?|骰子出现的数值列表.count(1)|"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8236a317",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ca91c2e2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30b66ffc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52c03be3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a53a88ed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "774c1305",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "010b7513",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
